import { request } from "@/utils/service"
export interface ILoginData {
  /** admin 或 editor */
  username: string
  /** 密码 */
  password: string
  /** 验证码 */
  code: string
  /** 验证码暗值 */
  key: string
}

/** 获取登录验证码 */
export function getLoginCodeApi(key: string = '') {
  return request({
    url: "admin/login/getValidatCode",
    method: "get",
    params: { key }
  })
}
/** 登录并返回 Token */
export function loginApi(data: ILoginData) {
  return request({
    url: "admin/login/login",
    method: "post",
    data: {
      phone: data.username,
      password: data.password,
      code: data.code,
      key: data.key
    }
  })
}
/** 获取用户详情 */
export function getUserInfoApi() {
  return request({
    url: "admin/auth/getRoles",
    method: "get"
  })
}
